package src;

public class AESCipher {
    private final KeyExpansion keyExpansion = new KeyExpansion();
    private final ByteSubstitution byteSubstitution = new ByteSubstitution();
    private final MixColumns mixColumns = new MixColumns();
    private byte[] tmp = new byte[16];
    public void encrypt(byte[] data, byte[] secretKey, byte[] out){
        //轮密钥加
        RoundKey.xor_matrix(data, secretKey, 0, tmp);
        for (int i = 1; i <= 10; i++) {
            // 字节代换
            byteSubstitution.byte_substitution(tmp);
            // 行移位
            RowShift.row_shift(tmp);
            // 列混合
            if (i != 10) {
                mixColumns.mix_columns(tmp);
            }
            // 轮密钥加
            RoundKey.xor_matrix(tmp, secretKey, 16 * i, out);
            System.arraycopy(out, 0, tmp, 0, 16);
        }
    }
}
